package cn.linstudy.handler;

import cn.linstudy.vo.result.ResponseBean;
import java.lang.reflect.InvocationTargetException;

/**
 * @Author XiaoLin
 * @Date 2022/1/8 14:14
 * @Description
 */
public abstract class IJobHandler {

    /** success */
    public static final ResponseBean<String> SUCCESS = new ResponseBean<String>(200, null);
    /** fail */
    public static final ResponseBean<String> FAIL = new ResponseBean<String>(500, null);
    /** fail timeout */
    public static final ResponseBean<String> FAIL_TIMEOUT = new ResponseBean<String>(502, null);


    /**
     * execute handler, invoked when executor receives a scheduling request
     *
     * @param param
     * @return
     * @throws Exception
     */
    public abstract ResponseBean<String> execute(String param) throws Exception;


    /**
     * init handler, invoked when JobThread init
     */
    public void init() throws InvocationTargetException, IllegalAccessException {
        // do something
    }


    /**
     * destroy handler, invoked when JobThread destroy
     */
    public void destroy() throws InvocationTargetException, IllegalAccessException {
        // do something
    }
}
